{{ define "content" }}

<div class="nav-title">
    <a href="/">{{.SiteCf.Name}}</a> &raquo; 用户列表：
    <a href="/admin/user/list?flag=0">已禁用0</a> |
    <a href="/admin/user/list?flag=1">待审核1</a> |
    <a href="/admin/user/list?flag=5">正常5</a> |
    <a href="/admin/user/list?flag=99">管理员99</a> |
</div>

<div class="main-box">

    <ul style="margin-left: 30px;padding: 0;">
    {{range $_, $item := .PageInfo.Items}}
    <li style="margin-bottom: 8px;">
        id:{{$item.Id}} - {{$item.Name}} - flag: {{$item.Flag}}
        <a href="/member/{{$item.Id}}">查看</a>
        <a href="/admin/user/edit/{{$item.Id}}">编辑</a>
    </li>
    {{end}}
    </ul>

    <div class="pagination">
        {{if .PageInfo.HasPrev}}
        <a href="/admin/user/list?flag={{.Flag}}&btn=prev&key={{.PageInfo.FirstKey}}" class="float-left">&laquo; 上一页</a>
        {{end}}
        {{if .PageInfo.HasNext}}
        <a href="/admin/user/list?flag={{.Flag}}&btn=next&key={{.PageInfo.LastKey}}" class="float-right">下一页 &raquo;</a>
        {{end}}
        <div class="c"></div>
    </div>

</div>

<div class="nav-title">
    <a href="/">{{.SiteCf.Name}}</a> &raquo; 添加用户
</div>

<div class="main-box">

    <form action="/login" method="post" onsubmit="return form_post();">
        <p><label>登录名： <input type="text" id="name" class="sl w200" value="" /></label>  <span class="fs12">允许字母、数字、中文，不能全为数字，4~12个字节</span></p>
        <p><label>密　码： <input type="text" id="password" class="sl w200" value="" /></label></p>

        <p><input type="submit" value=" 添加 " id="submit" class="textbtn newpostbtn" style="margin-left:60px;" /> </p>
    </form>

</div>

<script>

    function form_post(){
        var name = $('#name').val();
        var password = $('#password').val();
        if(name && password){
            $.ajax({
                type: "POST",
                url: "/admin/user/list",
                data: JSON.stringify({'act': 'new_user', 'name': name, 'password': md5(password)}),
                dataType: "json",
                success: function(data){
                    if(data.retcode==200){
                        window.location.href = "/admin/user/list?flag=5";
                    }else{
                        $.toast(data.retmsg);
                    }
                },
                fail: function(errMsg) {
                    $.toast(errMsg);
                }
            });
        }else{
            $.toast('用户名和密码必填');
        }
        return false;
    }

</script>

{{ end}}

